<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <a href="/test">测试</a>

  <script>
    //获取 a 元素
    let a = document.querySelector('a');
    //绑定单击事件
    a.onclick = function(e){
      //阻止默认行为
      e.preventDefault();
      //调用 history.pushState 方法
      history.pushState({id: 20}, '', '/test');
    }
  </script>
</body>
</html>